home *** CD-ROM | disk | FTP | other *** search
/ Chip 1996 October / CHIP Ekim 1996.iso / winbatch / exceldde.wb_ < prev    next >
Text File  |  1994-08-29  |  2KB  |  63 lines

  1.  
  2. ;Excel DDE Example
  3. ;This code makes a multiplication table in Excel via DDE
  4.                                                          ; Find Excel
  5.          a=FileLocate("excel.exe")                       ; Try brute force path search
  6.          if a=="" then a=IniRead("extensions","xls","")  ; No? Try via [extensions] section
  7.          terminate(a=="","Error","Excel not found")      ; Not installed normally
  8.          b=strindex(a," ",0,@FWDSCAN)                    ; Find first space
  9.          if b==0 then b=strlen(a)+1                      ; None? ...adjust b
  10.          b=strsub(a,1,b-1)                               ; Pick off ^.xls stuff
  11.          run(b,"")                                       ; Run Excel
  12.  
  13.          channel = DDEInitiate("Excel", "Sheet1")
  14.  
  15.          Numbers="One Two Three Four Five Six Seven Eight Nine Ten"
  16.  
  17.          offset=1
  18.          row=0
  19.  
  20.          :rowloop
  21.          col=0
  22.          row=row+1
  23.          if row > 10 then goto byebye
  24.  
  25.          ThisNum=ItemExtract(row,Numbers," ")
  26.          title=row+offset
  27.          DDEPoke(channel, "R1C%title%", ThisNum)
  28.          DDEPoke(channel, "R%title%C1", ThisNUm)
  29.  
  30.          :colloop
  31.          col=col+1
  32.          if col > 10 then goto rowloop
  33.  
  34.          expression="=%row%*%col%"
  35.          address=strcat("R",row+offset,"C",col+offset)
  36.          DDEPoke(channel,address,expression)
  37.          goto colloop
  38.  
  39.          :byebye
  40.          DDETerminate(channel)
  41.          Message("WinBatch DDE Sample","Complete")
  42.          
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.